package customerEnter.Frame.Utils;

import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.UUID;

public class HelpClass {

	private static String	imgName;
	private static String	ext;
	private static String	dayFileName;

	public static void main(String[] args) {
		System.out.println(HelpClass.getDayFileName());
	}

	/**
	 * 根據時間生成字符串(圖片的名字)
	 * 
	 * @return
	 */
	public static String getImgName() {
		Date currTime = new Date();
		SimpleDateFormat formatter2 = new SimpleDateFormat("yyyyMMddhhmmss", Locale.US);
		imgName = new String(formatter2.format(currTime));
		return imgName + UUID.randomUUID().toString();
	}

	public static String getDayFileName() {
		Date currTime = new Date();
		SimpleDateFormat formatter2 = new SimpleDateFormat("yyyyMM", Locale.US);
		dayFileName = new String(formatter2.format(currTime));
		return dayFileName;
	}

	/**
	 * 獲取文件的後綴名
	 * 
	 * @param file
	 * @return
	 */
	public static String getFileExt(File file) {
		String fileName = file.getName();
		ext = fileName.substring(fileName.lastIndexOf(".") + 1);
		return ext;
	}
}
